package Solution101_200;

/**
 * @program Leetcode
 * @description:
 * @author: lishangsheng
 * @create: 2019/07/18 22:08
 */
public class Solution121股票 {
    public int maxProfit(int prices[]) {
        int minPrice = Integer.MAX_VALUE;
        int maxProfit = 0;
        for (int i = 0; i < prices.length; i++) {
            if (prices[i] < minPrice)
                minPrice = prices[i];
            else if (prices[i] - minPrice > maxProfit)
                maxProfit = prices[i] - minPrice;
        }
        return maxProfit;
    }


}
